# -*-coding:utf-8-*-

import pymongo
import sys

if 2 != len(sys.argv):
    print 'Usage: python %s <DEVICE_ID>' % sys.argv[0]
    sys.exit()

device_id = sys.argv[1]
devices_states = pymongo.MongoClient().bora.devices_states

print 'Document count: %d' % devices_states.find().count()

for a in devices_states.find({'device_id': {'$regex': device_id}}):
    print a
